#ifndef SOCKETCLIENT_H
#define SOCKETCLIENT_H

#include "BaseGlobal.h"

#include <QTcpSocket>
#include <QHostAddress>

class BASE_EXPORT SocketClient : public QTcpSocket
{
	Q_OBJECT

public:
	SocketClient(QObject *parent = 0);
	~SocketClient();

public:
	bool connectToServer(const QHostAddress & addr, int port);

	bool postHeartBeat();
	bool sendData(const QByteArray & send);
	bool sendData(const QByteArray & send, qint64 & sendsize);
	bool requestData(const QByteArray & send, QByteArray & received, QString & strError);

public slots:
	void onDisconnect();
	void onDataReceived();

signals:
	void evtDisconnect(SocketClient *);
	void evtDataReceived(SocketClient *, const QByteArray &);

private:
	bool bAlive;
	QByteArray arrReceivedData;
};

#endif // SOCKETCLIENT_H
